package com.hqyj.onlineExamination.modules.exam.entity;

import java.util.Arrays;

/**
 * @author yun
 * @date 2021-5-25 10:45
 * 题目类型
 */
public enum QuestionType {
    SINGLE_CHOICE("singleChoice", "单选题", 2.5, 8),
    MULTIPLE_CHOICE("multipleChoice", "多选题", 5, 4),
    JUDGE("judge", "判断题", 2.5, 4),
    FILL_BLANK("fillBlank", "填空题", 2.5, 4),
    SHORT_ANSWER("shortAnswer", "简答题", 5, 2),
    PROGRAMMING("programming", "编程题", 15, 2);

    public String name;
    public String localName;
    public double score;
    public int baseNumber;

    private QuestionType(String name, String localName, double score, int baseNumber) {
        this.name = name;
        this.localName = localName;
        this.score = score;
        this.baseNumber = baseNumber;
    }

    public static QuestionType getQuestionType(String name) {
        QuestionType questionType = Arrays.asList(QuestionType.values()).stream()
                .filter(item -> item.name.equals(name))
                .findFirst()
                .orElse(null);
        return questionType == null ? null : questionType;
    }
}
